package com.browan.constellation.util;

import java.io.StringReader;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;

import com.browan.constellation.data.RSSData;

public class RSSParser
{
	public static List<RSSData> parseUrl(String xmlContent)
	{
		return parseUrl(xmlContent, 0);
	}

	private static List<RSSData> parseUrl(String url, long lastBuildDate)
	{
		SAXParserFactory factory = SAXParserFactory.newInstance();
		try
		{
			SAXParser parser = factory.newSAXParser();
			RssSaxParser parX = new RssSaxParser();
			parser.parse(new InputSource(new StringReader(url)), parX);
			return parX.getRss();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}
}